package com.yuhuihui.common.utils.excel.read.parameters;

import com.yuhuihui.common.utils.MapUtil;
import com.yuhuihui.common.utils.excel.read.convert.CellTypeConvertFactory;
import org.apache.poi.ss.usermodel.Cell;

import java.util.Map;
import java.util.Set;

/**
 * excel导入单元格参数
 *
 * @author yuhh
 * @date 2022-08-22 16:29:55
 */
public class ExcelReadCellParameter {

    /**
     * 单元格数据
     */
    private Cell cell;

    /**
     * 字段code
     */
    private String fieldCode;

    /**
     * 需要替换的数据
     * 第一个key是需要替换的字段名
     * 第二个key是excel中需要替换的值
     * 第二个value是替换后的值
     */
    private Map<String, Map<String, Object>> replaceInfo;

    /**
     * 默认值，key为字段名称
     */
    private Map<String, Object> defaultValue;

    /**
     * 替换信息
     */
    private Set<String> replaceInfoKeys;

    /**
     * 默认信息
     */
    private Set<String> defaultValueKeys;

    /**
     * 单元格类型装换工厂类
     */
    private CellTypeConvertFactory cellTypeConvertFactory;

    public ExcelReadCellParameter(Cell cell, String fieldCode, Map<String, Map<String, Object>> replaceInfo,
                                  Map<String, Object> defaultValue, CellTypeConvertFactory cellTypeConvertFactory){
        this.cell = cell;
        this.fieldCode = fieldCode;
        this.replaceInfo = replaceInfo;
        this.defaultValue = defaultValue;
        this.cellTypeConvertFactory = cellTypeConvertFactory;
        this.replaceInfoKeys = MapUtil.getKeys(replaceInfo);
        this.defaultValueKeys = MapUtil.getKeys(defaultValue);
    }

    public ExcelReadCellParameter(){

    }

    public Cell getCell() {
        return cell;
    }

    public void setCell(Cell cell) {
        this.cell = cell;
    }

    public String getFieldCode() {
        return fieldCode;
    }

    public void setFieldCode(String fieldCode) {
        this.fieldCode = fieldCode;
    }

    public Map<String, Map<String, Object>> getReplaceInfo() {
        return replaceInfo;
    }

    public void setReplaceInfo(Map<String, Map<String, Object>> replaceInfo) {
        this.replaceInfo = replaceInfo;
    }

    public Map<String, Object> getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(Map<String, Object> defaultValue) {
        this.defaultValue = defaultValue;
    }

    public Set<String> getReplaceInfoKeys() {
        return replaceInfoKeys;
    }

    public void setReplaceInfoKeys(Set<String> replaceInfoKeys) {
        this.replaceInfoKeys = replaceInfoKeys;
    }

    public Set<String> getDefaultValueKeys() {
        return defaultValueKeys;
    }

    public void setDefaultValueKeys(Set<String> defaultValueKeys) {
        this.defaultValueKeys = defaultValueKeys;
    }

    public CellTypeConvertFactory getCellTypeConvertFactory() {
        return cellTypeConvertFactory;
    }

    public void setCellTypeConvertFactory(CellTypeConvertFactory cellTypeConvertFactory) {
        this.cellTypeConvertFactory = cellTypeConvertFactory;
    }
}
